﻿using System;
using System.IO;
using System.Net;
using System.Text;

namespace TCL.FUNC
{
    public class SEO
    {
        public static String NotifyBot_Sitemap_Change()
        {
            StringBuilder lstBot = new StringBuilder();
            try
            {
                using (var client = new WebClient())
                {
                    using (var stream = client.OpenRead("http://www.google.com/webmasters/sitemaps/ping?sitemap=http://nguyenmanhthang.net/sitemap.xml"))
                    using (var textReader = new StreamReader(stream, Encoding.UTF8, true))
                    {
                        lstBot.Append("Google");
                    }
                    using (var stream = client.OpenRead("http://www.bing.com/webmaster/ping.aspx?sitemap=http://nguyenmanhthang.net/sitemap.xml"))
                    using (var textReader = new StreamReader(stream, Encoding.UTF8, true))
                    {
                        lstBot.Append("Bing");
                    }
                    using (var stream = client.OpenRead("http://coccoc.com/log?action=addUrlFromWebMaster&url=http://nguyenmanhthang.net/sitemap.xml&r=611037"))
                    using (var textReader = new StreamReader(stream, Encoding.UTF8, true))
                    {
                        lstBot.Append("CocCoc");
                    }
                }
            }
            catch (Exception ex)
            {
                lstBot.Append(ex.ToString());
            }
            return lstBot.ToString();
        }
    }
}
